﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace API.Models.Repository
{
    public class ALLOW_ITEMS_Repository : GenericRepository<PartnerDbContext, WH_ITEMS>
    {
        public override IQueryable<WH_ITEMS> Find(System.Linq.Expressions.Expression<Func<WH_ITEMS, bool>> predicate)
        {
            IQueryable<WH_ITEMS> query = _entities.WH_ITEMS
                .Include("COMPANY");

            /// Фильтрация по заданному условию
            if (predicate != null)
                query = query.Where(predicate);

            if (session != null)
            {
                query = query
                    //.Where(r => session.USER.COMPANIES.Select(n => n.COMPANY_GUID).Contains(r.COMPANY_GUID))
                    .AsQueryable();
            }

            return query;
        }
    }
}